package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;

/**
 * 攻略文章明细
 */
@Getter
@Setter
public class StrategyDetail extends BaseDomain{
    private String title;

    private Date createTime;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date releaseTime;

    private Integer sequence;

    private StrategyCatalog catalog;

    private String coverUrl;

    private Boolean state=false;//发布/不发布

    //关联文章内容
    private StrategyContent strategyContent;

    public String getStateName(){
        String msg="未发布";
        if(this.state){
            msg="发布";
        }
        return msg;
    }
    public String getJson(){
        HashMap map = new HashMap<>();
        map.put("id",id);
        map.put("title",title);
        map.put("sequence",sequence);
        map.put("coverUrl",coverUrl);
        map.put("state",state);
        if(catalog!=null){
        //攻略分类的id
        map.put("catalogId",catalog.getId());
        //所属攻略的id
        map.put("strategyId",catalog.getStrategy().getId());
        }
        return JSONUtil.toJSONString(map);
    }


}